<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>异步函数-2</title>
</head>

<body>
    <!-- 处理异常的机制将用 try-catch 块实现： -->
    <script>
        async function asyncFunc() {
            try {
                await new Promise(function (resolve, reject) {
                    throw "Some error"; // 或者 reject("Some error")
                });
            } catch (err) {
                console.log(err);
                // 会输出 Some error
            }
        }
        asyncFunc();
    </script>
</body>

</html>